﻿using System;
using Newtonsoft.Json;

namespace OrkutAPILibrary.Entities
{
    /// <summary>
    /// Orkut Comment
    /// </summary>
    public class OrkutComment
    {
        /// <summary>
        /// Gets or sets the comment body.
        /// </summary>
        /// <value>The comment body.</value>
        [JsonProperty(PropertyName = "text")]
        public string CommentBody { get; set; }

        /// <summary>
        /// Gets or sets the created time.
        /// </summary>
        /// <value>The created time.</value>
        public DateTime CreatedTime { get; internal set; }

        internal static readonly DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

        [JsonProperty(PropertyName = "created")]
        internal string _createdTime
        {
            get
            {
                return (CreatedTime - unixEpoch).TotalSeconds.ToString();
            }
            set
            {
                CreatedTime = unixEpoch.AddSeconds(Convert.ToInt32(value));
            }
        }

        /// <summary>
        /// Gets or sets the created by id.
        /// </summary>
        /// <value>The created by id.</value>
        [JsonProperty(PropertyName = "authorId")]
        public string CreatedById { get; internal set; }

        /// <summary>
        /// Gets or sets the comment id.
        /// </summary>
        /// <value>The comment id.</value>
        [JsonProperty(PropertyName = "id")]
        public string CommentId { get; internal set; }
        
    }
}
